﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using FrameConstructor;

namespace TetrisShape
{
    public class Block
    {
        private int x = 0;
        private int y = 0;
        public static int Speed = 500;

        public int X
        {
            get { return x; }
            protected set { x = value; }
        }

        public int Y
        {
            get { return y; }
            protected set { y = value; }
        }
        public Block()
        { }

        public Block(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }

        //Moved block in down for one unit
        public void DoStep(Shape sh)
        {
            foreach (Block bl in sh.returnBlock)
            {
                bl.Y += 1;
            }
            Thread.Sleep(Speed);
        }
        //Moved block on left for one unit
        public void BlockMoveLeft(Shape sh, Frame fr)
        {
            int i = 0;

            foreach (Block bl in sh.returnBlock)
            {
                if (bl.X == fr.StartX + 1)
                    i = 1;
            }
            if (i != 1)
                foreach (Block block in sh.returnBlock)
                {
                    block.X -= 1;
                }
        }
        //Moved block on right for one unit
        public void BlockMoveRight(Shape sh, Frame fr)
        {
            int i = 0;

            foreach (Block bl in sh.returnBlock)
            {
                if (bl.X == fr.StartX + 10)
                    i = 1;
            }
            if (i != 1)
                foreach (Block block in sh.returnBlock)
                {
                    block.X += 1;
                }
        }

        public void SetX(int x)
        {
            X = x;
        }

        public void SetY(int y)
        {
            Y = y;
        }
    }
}

